package com.github.catvod.spider.merge;

/* loaded from: classes.dex */
abstract class B {
    i h;

    static class HA extends B {
        private String V0;

        HA() {
            super();
            this.h = i.Character;
        }

        HA i4(String str) {
            this.V0 = str;
            return this;
        }

        @Override // com.github.catvod.spider.merge.B
        B t() {
            this.V0 = null;
            return this;
        }

        public String toString() {
            return y();
        }

        String y() {
            return this.V0;
        }
    }

    static final class W extends B {
        W() {
            super();
            this.h = i.EOF;
        }

        @Override // com.github.catvod.spider.merge.B
        B t() {
            return this;
        }

        public String toString() {
            return "";
        }
    }

    static final class c extends B {
        final StringBuilder I;
        final StringBuilder V0;
        String j;
        boolean oC;
        final StringBuilder q;

        c() {
            super();
            this.V0 = new StringBuilder();
            this.j = null;
            this.q = new StringBuilder();
            this.I = new StringBuilder();
            this.oC = false;
            this.h = i.Doctype;
        }

        public boolean GM() {
            return this.oC;
        }

        String PD() {
            return this.q.toString();
        }

        String i4() {
            return this.V0.toString();
        }

        public String j5() {
            return this.I.toString();
        }

        @Override // com.github.catvod.spider.merge.B
        B t() {
            B.n(this.V0);
            this.j = null;
            B.n(this.q);
            B.n(this.I);
            this.oC = false;
            return this;
        }

        String y() {
            return this.j;
        }
    }

    static final class d extends B {
        private final StringBuilder V0;
        private String j;
        boolean q;

        d() {
            super();
            this.V0 = new StringBuilder();
            this.q = false;
            this.h = i.Comment;
        }

        private void PD() {
            String str = this.j;
            if (str != null) {
                this.V0.append(str);
                this.j = null;
            }
        }

        final d i4(char c) {
            PD();
            this.V0.append(c);
            return this;
        }

        String j5() {
            String str = this.j;
            return str != null ? str : this.V0.toString();
        }

        @Override // com.github.catvod.spider.merge.B
        B t() {
            B.n(this.V0);
            this.j = null;
            this.q = false;
            return this;
        }

        public String toString() {
            return "<!--" + j5() + "-->";
        }

        final d y(String str) {
            PD();
            if (this.V0.length() == 0) {
                this.j = str;
            } else {
                this.V0.append(str);
            }
            return this;
        }
    }

    public enum i {
        Doctype,
        StartTag,
        EndTag,
        Comment,
        Character,
        EOF
    }

    static abstract class j extends B {
        private boolean BQ;
        private StringBuilder I;
        QF Qy;
        protected String V0;
        private boolean W;
        protected String j;
        private String oC;
        private String q;
        boolean u;

        j() {
            super();
            this.I = new StringBuilder();
            this.BQ = false;
            this.W = false;
            this.u = false;
        }

        private void w4() {
            this.W = true;
            String str = this.oC;
            if (str != null) {
                this.I.append(str);
                this.oC = null;
            }
        }

        final String C4() {
            String str = this.V0;
            R2.V0(str == null || str.length() == 0);
            return this.V0;
        }

        final void GM(int[] iArr) {
            w4();
            for (int i : iArr) {
                this.I.appendCodePoint(i);
            }
        }

        final void Ig() {
            if (this.Qy == null) {
                this.Qy = new QF();
            }
            String str = this.q;
            if (str != null) {
                String trim = str.trim();
                this.q = trim;
                if (trim.length() > 0) {
                    this.Qy.q(this.q, this.W ? this.I.length() > 0 ? this.I.toString() : this.oC : this.BQ ? "" : null);
                }
            }
            this.q = null;
            this.BQ = false;
            this.W = false;
            B.n(this.I);
            this.oC = null;
        }

        final void LW() {
            if (this.q != null) {
                Ig();
            }
        }

        final boolean Og(String str) {
            QF qf = this.Qy;
            return qf != null && qf.t(str);
        }

        final void PD(char c) {
            w4();
            this.I.append(c);
        }

        final void PU(char c) {
            yx(String.valueOf(c));
        }

        final boolean R() {
            return this.Qy != null;
        }

        final String T() {
            String str = this.V0;
            return str != null ? str : "[unset]";
        }

        final boolean b() {
            return this.u;
        }

        final j f(String str) {
            this.V0 = str;
            this.j = AR.h(str);
            return this;
        }

        final void i4(char c) {
            y(String.valueOf(c));
        }

        final void j5(String str) {
            w4();
            if (this.I.length() == 0) {
                this.oC = str;
            } else {
                this.I.append(str);
            }
        }

        final String l() {
            return this.j;
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // com.github.catvod.spider.merge.B
        /* renamed from: nf, reason: merged with bridge method [inline-methods] */
        public j t() {
            this.V0 = null;
            this.j = null;
            this.q = null;
            B.n(this.I);
            this.oC = null;
            this.BQ = false;
            this.W = false;
            this.u = false;
            this.Qy = null;
            return this;
        }

        final void rd() {
            this.BQ = true;
        }

        final void y(String str) {
            String str2 = this.q;
            if (str2 != null) {
                str = str2.concat(str);
            }
            this.q = str;
        }

        final void yx(String str) {
            String str2 = this.V0;
            if (str2 != null) {
                str = str2.concat(str);
            }
            this.V0 = str;
            this.j = AR.h(str);
        }
    }

    static final class qM extends j {
        qM() {
            this.h = i.EndTag;
        }

        public String toString() {
            return "</" + T() + ">";
        }
    }

    static final class x extends j {
        x() {
            this.h = i.StartTag;
        }

        x V(String str, QF qf) {
            this.V0 = str;
            this.Qy = qf;
            this.j = AR.h(str);
            return this;
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // com.github.catvod.spider.merge.B.j, com.github.catvod.spider.merge.B
        /* renamed from: nf */
        public j t() {
            super.t();
            this.Qy = null;
            return this;
        }

        public String toString() {
            if (!R() || this.Qy.size() <= 0) {
                return "<" + T() + ">";
            }
            return "<" + T() + " " + this.Qy.toString() + ">";
        }
    }

    static final class yh extends HA {
        yh(String str) {
            i4(str);
        }

        @Override // com.github.catvod.spider.merge.B.HA
        public String toString() {
            return "<![CDATA[" + y() + "]]>";
        }
    }

    static void n(StringBuilder sb) {
        if (sb != null) {
            sb.delete(0, sb.length());
        }
    }

    final boolean BQ() {
        return this.h == i.Character;
    }

    final boolean F8() {
        return this.h == i.StartTag;
    }

    final x I() {
        return (x) this;
    }

    final boolean Qy() {
        return this.h == i.EOF;
    }

    final d V0() {
        return (d) this;
    }

    final boolean W() {
        return this.h == i.Comment;
    }

    final HA h() {
        return (HA) this;
    }

    String iU() {
        return getClass().getSimpleName();
    }

    final c j() {
        return (c) this;
    }

    final boolean oC() {
        return this instanceof yh;
    }

    final boolean oq() {
        return this.h == i.EndTag;
    }

    final qM q() {
        return (qM) this;
    }

    abstract B t();

    final boolean u() {
        return this.h == i.Doctype;
    }

    private B() {
    }
}
